
<template>
  <div class="greetings">
    <h1 class="green">{{ msg }}</h1>
    <h3>
      You’ve successfully created a project with
      <a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
      <a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
    </h3>
  </div>
  <div>
    <button @click="fetchData1">调用接口get0</button>
    <button @click="fetchData2">调用接口get1</button>
    <button @click="fetchData3">调用接口get2</button>
    <button @click="fetchData4">调用后台接口</button>
  </div>
  <router-link to="/MainPage">Main</router-link> |
      <router-link to="/LoginPage">Login</router-link> |
      <router-link to="/RegisterPage">Register</router-link> |
      <router-link to="/MyPage">my</router-link> |
      <router-link to="/HelloWorldA">HelloWorldA</router-link> 
</template>

<script>
import { fetchArticle } from '@/api/article'
//https://blog.csdn.net/dyw3390199/article/details/111401089
export default {
  name: "HelloWorld",
  data() {
    return {
      loading: false
    }
  },
  methods: {
    fetchData1() {
      this.axios.get(this.urlA+'/v1/api/test/get')
        .then(response => {
          // 请求成功的回调函数
          console.log(response.data)
        }).catch(error => {
          // 请求失败的回调函数
          console.error(error)
        })
    },
    fetchData2() {
      this.axios.get(this.urlA+'/v1/api/test/get1/1111'
        ).then(response => {
          // 请求成功的回调函数
          console.log(response.data)
        }).catch(error => {
          // 请求失败的回调函数
          console.error(error)
        })
    },
    fetchData3() {
      this.axios.get(this.urlA+'/v1/api/test/get2', 
      {
        params: {
           abc: "10a",
           age:2000
           }
          }).then(function (response) {
            console.log(response);
          })
          .catch(function (error) {
            console.log(error);
          })
    },
    fetchData4() {
      fetchArticle().then(response => {
        console.log(response.data)
      }).catch(err => {
        console.log(err)
      })
    },
  }
}
</script>

<script setup>
defineProps({
  msg: {
    type: String,
    required: true
  }
})
</script>



<style scoped>
h1 {
  font-weight: 500;
  font-size: 2.6rem;
  position: relative;
  top: -10px;
}

h3 {
  font-size: 1.2rem;
}

.greetings h1,
.greetings h3 {
  text-align: center;
}

@media (min-width: 1024px) {
  .greetings h1,
  .greetings h3 {
    text-align: left;
  }
}
</style>
